package han.chensing.latos.common.level.content.timeLine.frame;

import han.chensing.latos.common.level.function.TimeObject;

public abstract class BaseFrame<E extends Enum<?>> implements TimeObject {
    protected float time;
    protected E[] eventTypes;
    protected int eventTypePosition=0;

    @SafeVarargs
    public final void addTypes(E... eventTypes){
        if (eventTypes==null) return;
        for (E eventType : eventTypes) {
            if (eventType==null)continue;
            if (hasType(eventType)) continue;
            this.eventTypes[eventTypePosition++]=eventType;
        }
    }

    public boolean hasType(E eventType){
        for (E type : eventTypes)
            if (type==eventType)
                return true;
        return false;
    }

    public E[] getEventTypes() {
        return eventTypes;
    }

    public void setTime(float time) {
        this.time = time;
    }

    @Override
    public float getTime() {
        return time;
    }
}
